package com.s7.widget.attr;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;

import com.s7.widget.R;
import com.s7.widget.utils.PxUtil;

/**
 * Created by anderson on 2016/6/5.
 */
public class DashboardAttr {

    /**
     * 是否允许拖动
     */
    private boolean isDragging;
    // 是否取整
    private boolean isTrunc;
    // 起始值
    private float mStart;
    // 结束值
    private float mEnd;
    // 起始值颜色
    private int startColor;
    // 结束值颜色
    private int endColor;
    //进度弧的宽度
    private int progressWidth;
    // 进度条总占角度
    private int duringArc;
    // 进度条指示器颜色
    private int indicatorColor;

    // 刻度个数
    private int mCount;
    // 刻度间隔数
    private int mCountGroup;
    // 刻度文字显示规则
    private int mCountRule;
    // 单位
    private String mUnit;
    //背景颜色
    private int backgroundColor;
    // 内圆颜色
    private int centerCircleColor;
    //字体颜色
    private int textColor;
    //字体大小
    private int textSize;

    public DashboardAttr(Context context, AttributeSet attrs, int defStyleAttr) {
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.DashBoard, defStyleAttr, 0);

        backgroundColor = ta.getColor(R.styleable.DashBoard_dbBackground, 0);
        centerCircleColor = ta.getColor(R.styleable.DashBoard_dbCenterCircle, 0xFF00C1F8);
        isDragging = ta.getBoolean(R.styleable.DashBoard_dbDragging, false);
        isTrunc = ta.getBoolean(R.styleable.DashBoard_dbTrunc, false);
        mStart = ta.getInt(R.styleable.DashBoard_dbStart, 0);
        mEnd = ta.getInt(R.styleable.DashBoard_dbEnd, 240);
        startColor = ta.getColor(R.styleable.DashBoard_dbStartColor, 0xFF08D2F2);
        endColor = ta.getColor(R.styleable.DashBoard_dbEndColor, 0xFFDD0139);
        mCount = ta.getInt(R.styleable.DashBoard_dbCount, 12);
        mCountGroup = ta.getInt(R.styleable.DashBoard_dbCountGroup, 5);
        mCountRule = ta.getInt(R.styleable.DashBoard_dbCountRule, 0);

                ta.getInt(R.styleable.DashBoard_dbCountRule, 0);
        duringArc = ta.getInt(R.styleable.DashBoard_dbDuringArc, 240);
        progressWidth = ta.getInt(R.styleable.DashBoard_dbProgressWidth, 15);
        indicatorColor = ta.getColor(R.styleable.DashBoard_dbIndicator, 0xFFFFFFFF);

        mUnit = ta.getString(R.styleable.DashBoard_dbUnit);
        textColor = ta.getColor(R.styleable.DashBoard_dbTextColor, 0xFFFFFFFF);
        textSize = ta.getDimensionPixelSize(PxUtil.spToPx(R.styleable.DashBoard_dbTextSize, context), 40);
        ta.recycle();
    }

    public boolean isDragging() {
        return isDragging;
    }

    public boolean isTrunc() {
        return isTrunc;
    }

    public float getStart() {
        return mStart;
    }

    public float getEnd() {
        return mEnd;
    }

    public int getStartColor() {
        return startColor;
    }

    public int getEndColor() {
        return endColor;
    }

    public int getIndicatorColor() {
        return indicatorColor;
    }

    public int getProgressWidth() {
        return progressWidth;
    }

    public int getDuringArc() {
        return duringArc;
    }

    public int getCount() {
        return mCount;
    }

    public int getCountGroup() {
        return mCountGroup;
    }

    public int getCountRule() {
        return mCountRule;
    }

    public String getUnit() {
        return mUnit;
    }

    public int getBackgroundColor() {
        return backgroundColor;
    }

    public int getCenterCircleColor() {
        return centerCircleColor;
    }

    public int getTextColor() {
        return textColor;
    }

    public int getTextSize() {
        return textSize;
    }
}
